﻿<cfsilent>
	<cfscript>

		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
	
		sql = "SELECT  a.institute_id,
					   a.institute_name 
				FROM t_institute a  
				WHERE a.classification = '1' 
					  OR 
					  a.classification = '3' 
				ORDER BY a.institute_name ";
		queryObj = new Query( datasource=application.dnsSlave ); 
		rs_host = queryObj.execute( sql=sql ).getResult();	
		
		sql = "SELECT 
					count(*) num, 
					b.institute_id, 
					b.institute_name, 
					b.classification
				FROM t_course a  
					 INNER JOIN t_institute b ON b.institute_id = a.institute_id  
				GROUP BY 
					b.institute_id, 
					b.institute_name, 
					b.classification 
				ORDER BY 
					b.classification, b.institute_name ";
		queryObj = new Query( datasource=application.dnsSlave ); 
		rs_ins = queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT a.cat_id,a.cat_name 
				FROM t_course_catalog a  
				ORDER BY a.cat_id  ";
		queryObj = new Query( datasource=application.dnsSlave ); 
		rs_cat = queryObj.execute( sql=sql ).getResult();
		

		event.setArg("pageTitle", "教学运行基础数据 - 课程库维护");

		targetArgs = structNew();
	
		currentTab = event.getArg("TabID", "labCourse");
	
		if ( rs_ins.recordCount GT 0 ) {
			currentTab = "labImport";
		}
		
		/* 搜索课程 */
		keyword = event.getArg("Keywords");
		
		//searchArray = [];
		rs_search = queryNew("cid");
		
		if ( len(keyword) ) {
			
			sql = "SELECT 
						a.cid, a.course_name, 
						a.course_code, a.course_credit, 
						a.period, a.period_theory, 
						a.period_practice, a.period_computer,
						a.period_week, a.mark_mode, 
						a.institute_id, a.abandon 
					FROM t_course a  
					WHERE 
						a.course_code LIKE :condition 
						OR 
						a.course_name LIKE :condition 
					ORDER BY a.course_name  ";	
			queryObj = new Query( datasource=application.dnsSlave,maxRows=20  ); 
			queryObj.addParam( name="condition", value=keyword&"%" , cfsqltype="cf_sql_varchar" );
			rs_search = queryObj.execute( sql=sql ).getResult();
			
			currentTab = "labSearch";
		}


	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('programSchema')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">培养方案</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i>课程概况
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labCourse">class="active"</cfif> id="labCourse" tabTarget="Course">开课学院概况</span>
						<span <cfif currentTab eq "labCreate">class="active"</cfif> id="labCreate" tabTarget="Create">设置新课程</span>
						<span <cfif currentTab eq "labImport">class="active"</cfif> id="labImport" tabTarget="Import">批量导入课程数据</span>
						<span <cfif currentTab eq "labSearch">class="active"</cfif> id="labSearch" tabTarget="Search">搜索</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="Course" class="tabContent">
				
					<cfif rs_ins.recordCount>
							
							<div class="noticeBlock">
								<div class="operation">
									<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('courseDownloadExcel', targetArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载课程数据</span></a>
								</div>
								<h3>开课部门信息</h3>
								<p><span class="img icon16x16 message"></span>如果您需要设置新的课程信息, 请通过上方的 "设置新课程" 标签添加计划课程信息.</p>
								<hr/>
							</div>
							
							<div class="clearfix">
								<div class="UICardTable">
                                    <cfloop query="rs_ins" >
										<cfset structInsert(targetArgs, "DepID", rs_ins.institute_id, true) />
										<dl>
											<dt>
												<a href="<cfoutput>#buildURL('courseByDepartment', targetArgs)#</cfoutput>">
												<em class="collection"><!--imgholder--></em>
												<dd>
													<h3><cfoutput>#rs_ins.institute_name#</cfoutput></h3>
													<div><cfoutput>#rs_ins.num#</cfoutput> 门课程</div>
												</dd>
												</a>
											</dt>
										</dl>
									</cfloop>
								</div>
							</div>
							
						<cfelse>
							<div class="systemNotice">
								<h3><span class="img icon16x16 info"></span>尚未设置课程信息</h3>
								<p>当前您还没有设置课程, 请通过上方的 "批量导入课程数据" 标签快速的构建教学课程库.</p>
							</div>
					</cfif>
				
				</div>
				
				<div id="Create" class="tabContent">
					
					<cfif event.getArg("courseExistsID") neq "">
						
						<div class="systemNotice">
							<h3><span class="img icon16x16 info"></span>《<cfoutput>#event.getArg('CourseName')#</cfoutput>》在开课学院有重复记录</h3>
							<p>您当前要求录入的课程《<cfoutput>#event.getArg('CourseName')#</cfoutput>》在课程库的存在已有记录. 任课单位在课程设置时, 必须保证课程名称唯一性.</p>
						</div>
						
					</cfif>
					
					<form id="formCreate" onSubmit="javascript:return processVerfiyForm('formCreate');" class="formWrapper " method="post" action="<cfoutput>#buildURL('courseCreateDo')#</cfoutput>">
						
						<div class="label">
							<span class="req">*</span><b>课程</b>
							<input name="CourseName" id="CourseName" type="text" class="typeTextShort" verification="required" maxlength="30" value="<cfoutput>#event.getArg('CourseName')#</cfoutput>" />
						</div>
						
						<div class="label">
							<span class="req">*</span><b>学分</b>
							<input name="Credit" id="Credit" type="text" class="typeTinyInt" verification="double" maxlength="4" value="<cfoutput>#event.getArg('Credit', '2.0')#</cfoutput>" />
						</div>
						
						<div class="label">
							<span class="req">*</span><b>学时分布</b>
							理论学时<input name="PeriodTheory" id="PeriodTheory" type="text" class="typeTinyInt" verification="integer" maxlength="4" value="<cfoutput>#event.getArg('PeriodTheory', '0')#</cfoutput>" />
							实践学时<input name="PeriodPractice" id="PeriodPractice" type="text" class="typeTinyInt" verification="integer" maxlength="4" value="<cfoutput>#event.getArg('PeriodPractice', '0')#</cfoutput>" />
							上机学时<input name="PeriodComputer" id="PeriodComputer" type="text" class="typeTinyInt" verification="integer" maxlength="4" value="<cfoutput>#event.getArg('PeriodComputer', '0')#</cfoutput>" />
						</div>
						
						<div class="label">
							<span class="req">*</span><b>课程号</b>
							<input name="CourseCode" id="CourseCode" type="text" class="typeCode" verification="required" maxlength="20" value="<cfoutput>#event.getArg('CourseCode')#</cfoutput>" />
							<p class="notice">如果学校对于课程有自己的编码规范, 您可以在这里手工指定现有课程的编码</p>
						</div>
						
						<div class="label">
							<b>计分模式</b>
							<select name="MarkMode">
								<option <cfif event.getArg('MarkMode') eq '0'>selected="selected"</cfif> value="0">百分制</option>
								<!---<option <cfif event.getArg('MarkMode') eq '2'>selected="selected"</cfif> value="2">两级制（通过、不通过）</option>--->
								<option <cfif event.getArg('MarkMode') eq '4'>selected="selected"</cfif> value="4">五级制（优秀、良好、中、及格、不及格）</option>
							</select>
						</div>
						
						<hr/>
						
						<div class="label">
							<b>安排补考</b>
							<input name="ResitPolicy" type="radio" class="typeRadio" value="1" <cfif event.getArg('ResitPolicy', '1') eq '1'>checked="checked"</cfif> />是
							<input name="ResitPolicy" type="radio" class="typeRadio" value="0" <cfif event.getArg('ResitPolicy') eq '0'>checked="checked"</cfif>/>否
						</div>
						
						<div class="label">
							<b>已停止开课</b>
							<input name="Abandon" type="radio" class="typeRadio" value="1" <cfif event.getArg('Abandon') eq '1'>checked="checked"</cfif> />是
							<input name="Abandon" type="radio" class="typeRadio" value="0" <cfif event.getArg('Abandon', '0') eq '0'>checked="checked"</cfif>/>否
						</div>
						
						<hr/>
						
						<div class="label">
							<b>排课周学时</b>
							<select name="PeriodPerWeek">
								<option <cfif event.getArg('PeriodPerWeek') eq '0'>selected="selected"</cfif> value="0">不排课</option>
								<option <cfif event.getArg('PeriodPerWeek') eq '2'>selected="selected"</cfif> value="2">每周一次课, 安排2小节</option>
								<option <cfif event.getArg('PeriodPerWeek') eq '3'>selected="selected"</cfif> value="3">每周一次课, 安排3小节</option>
								<option <cfif event.getArg('PeriodPerWeek') eq '4'>selected="selected"</cfif> value="4">每周两次课, 每次2小节 或 每周一次课, 连续4小节</option>
								<option <cfif event.getArg('PeriodPerWeek') eq '5'>selected="selected"</cfif> value="5">每周两次课, 一次2小节,一次3小节 或 每周一次课, 连续5小节</option>
								<option <cfif event.getArg('PeriodPerWeek') eq '6'>selected="selected"</cfif> value="6">每周三次课, 每次2小节 或 每周两次课, 每次3小节 或 一次4小节, 一次3小节</option>
								<option <cfif event.getArg('PeriodPerWeek') eq '8'>selected="selected"</cfif> value="8">每周四次课, 每次2小节 或 每周三次课, 两次3小节, 一次2小节 或 每周两次课,每次4小节</option>
								<option <cfif event.getArg('PeriodPerWeek') eq '10'>selected="selected"</cfif> value="10">每周五次课, 每次2小节 或 每周四次课, 两次3小节, 两次2小节</option>
								<option <cfif event.getArg('PeriodPerWeek') eq '16'>selected="selected"</cfif> value="16">每周四次课，每次4小节</option>
							</select>
						</div>
						
						<div class="label">
							<b>任课单位</b>
							<select name="InstituteID">
                                <cfloop query="rs_host" >
									<option <cfif event.getArg('InstituteID') eq rs_host.institute_id>selected="selected"</cfif> value="<cfoutput>#rs_host.institute_id#</cfoutput>"><cfoutput>#rs_host.institute_name#</cfoutput></option>
								</cfloop>
							</select>
						</div>
						
						<div class="label">
							<b>课程类别</b>
							<select name="CatID">
                                <cfloop query="rs_cat" >
									<option <cfif event.getArg('CatID') eq rs_cat.cat_id>selected="selected"</cfif> value="<cfoutput>#rs_cat.cat_id#</cfoutput>"><cfoutput>#rs_cat.cat_name#</cfoutput></option>
								</cfloop>
							</select>
						</div>
						
						<hr/>
						
						<div class="label">
							<b>英文名称</b>
							<input name="CourseEnglish" id="CourseEnglish" type="text" class="typeText typeEnglish" maxlength="180" value="<cfoutput>#event.getArg('CourseEnglish')#</cfoutput>" />
						</div>
						
						<div class="label">
							<b>课程介绍</b>
							<textarea name="Intro" id="Intro"><cfoutput>#event.getArg('Intro')#</cfoutput></textarea>
						</div>
						
						<div class="label">
							<b>参考书</b>
							<textarea name="ReferenceBooks" id="ReferenceBooks"><cfoutput>#event.getArg('ReferenceBooks')#</cfoutput></textarea>
						</div>
						
						<hr/>
						
						<div class="lable">
							<input class="button" type="submit" value="提交" />
							<input class="button" type="reset" value="重设表格" />
						</div>
						
					</form>

					
				</div>
				
				<div id="Import" class="tabContent">
					
					<div class="noticeBlock">
						<h3>导入课程基础数据</h3>
						<p><span class="img icon16x16 message"></span>请严格按照如下的数据模板在电子表格文件中录入课程基础数据. 点击<a href="<cfoutput>#buildURL('importCourseTemplate')#</cfoutput>">下载课程信息录入模板</a>, 在录入信息时请勿更改第一行表头内容.</p>
						<hr/>
						<table>
							<tr>
								<td>任课单位</td><td>课程名称</td><td>课程英文名称</td><td>学分</td><td>排课周学时</td><td>总学时</td><td>理论学时</td><td>实践学时</td><td>上机学时</td><td>课程简介</td><td>参考书目</td><td>课程号</td>
							</tr>
							<tr>
								<td>部门全称</td><td>大学外语[1]</td><td class="numeric">College English[1]</td><td class="numeric">4.0</td><td class="numeric">2</td><td class="numeric">48</td><td class="numeric">48</td><td class="numeric">0</td><td class="numeric">0</td><td>...</td><td>...</td><td class="numeric">111307090</td>
							</tr>
						</table>
						<br/>
						<p><span class="img icon16x16 link"></span>选填信息</p>
						<p><span class="img icon16x16 message"></span>只有您清楚的了解该课程类别含义再补充课程下述信息, 该课程信息会影响选、排课等教学运行.</p>
						<table>
							<tr>
								<td>课程类别</td>
							</tr>
							<tr>
								<td>本校课程 / 公共基础课 / 小语种外语 / 素质选修课 / 外校课程 / 体育选项目 / 创新实践学分</td>
							</tr>
						</table>
						<hr/>
					</div>
					
					<form target="output" onSubmit="javascript:return processVerfiyForm('formImport');" id="formImport" class="formWrapper" method="post" enctype="multipart/form-data" action="<cfoutput>#buildURL('importCourseDo')#</cfoutput>">
						
						<div class="label">
							<span class="req">*</span><b>导入数据文件</b>
							<input name="upload" id="upload" type="file" verification="required" />
						</div>
						
						<div class="lable"><input id="importTrigger" class="button" type="submit" value="导入课程数据" /></div>
					</form>
					
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						$(document).ready(function() {
							$("#importTrigger").click(function(){
								$("#output").attr("src","about:blank").removeClass("hidden_elem");
							});
						});
						// -->
						//]]>
					</script>
					
					<iframe name="output" id="output" class="UIframeBox hidden_elem" src="about:blank" frameborder="0"></iframe>
					
				</div>
				
				<div id="Search" class="tabContent">
					
					<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('programCourse')#</cfoutput>">
						<input type="hidden" name="TabID" value="labSearch" />
						
						<div class="label">
							<b>课程或课程号</b>
							<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
						</div>
						<hr/>
						<div class="lable">
							<input class="button1" type="submit" value="搜索" />
						</div>
					</form>
					
					<cfif rs_search.recordCount>
						
						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="18"></td>
									<td width="80">课程号</td>
									<td>课程</td>
									<td width="24" align="center">学分</td>
									<td width="50" align="center">计分</td>
									<td width="36" align="center">总学时</td>
									<td width="24" align="center">理论</td>
									<td width="24" align="center">实践</td>
									<td width="24" align="center">上机</td>
									<td width="36" align="center">周学时</td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_search" >
									<cfset row ++ />
									<cfset structInsert(targetArgs, "CID", rs_search.cid, true) />
									<cfset structInsert(targetArgs, "DepID", rs_search.institute_id, true) />
									<tr class="editRows <cfif rs_search.abandon eq "1"> cancelRow</cfif>">
										<td><span class="index"><cfoutput>#row#</cfoutput></span></td>
										<td><span class="numeric"><cfoutput>#rs_search.course_code#</cfoutput></span></td>
										<td><cfoutput>#rs_search.course_name#</cfoutput></td>
										<td align="center"><span class="numeric"><cfoutput>#numberFormat(rs_search.course_credit, "0.0")#</cfoutput></span></td>
										<td align="center"><cfoutput>#dictAdvice.getMarkModeName(rs_search.mark_mode)#</cfoutput></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_search.period#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_search.period_theory#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_search.period_practice#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_search.period_computer#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_search.period_week#</cfoutput></span></td>
										<td><a class="edit" href="<cfoutput>#buildURL('courseDetail', targetArgs)#</cfoutput>"></a></td>
									</tr>
								</cfloop>
							</tbody>
						</table>
						
					</cfif>
					
				</div>
				
			</div>
		</li>
	</ul>
</div>